#include "reverse_iterator.h"
#include "list.h"

using namespace xy;
using std::cout;
using std::endl;

struct A {
	int _a;
	int _b;

	A(int a = 0, int b =0) 
		:_a(a)
		,_b(b)
	{}
};

void test1() {
	list<int> ls;
	ls.push_back(1);
	ls.push_back(2);
	ls.push_back(3);
	ls.push_back(4);

	ls.push_front(1);
	ls.push_front(2);
	ls.push_front(3);
	ls.push_front(4);

	list<int>::iterator it = ls.begin();
	while (it != ls.end()) {
		cout << *it << ' ';
		++it;
	}
	cout << endl;
}

void test2() {
	list<A> ls;
	ls.push_back(A(1, 1));
	ls.push_back(A(2, 2));
	ls.push_back(A(3, 3));
	ls.push_back(A(4, 4));

	list<A>::iterator it = ls.begin();
	while (it != ls.end()) {
		cout << it->_a << ' ' << it->_b << endl;
		it++;
	}
	cout << endl;

	const list<A> lt;

	list<A>::const_iterator ita = lt.begin();
	while (ita != lt.end()) {
		cout << ita->_a << ' ' << ita->_b << endl;
		ita++;
	}
	cout << endl;
}

void test3() {
	list<int> ls;
	ls.push_back(1);
	ls.push_back(2);
	ls.push_back(3);
	ls.push_back(4);

	ls.push_front(1);
	ls.push_front(2);
	ls.push_front(3);
	ls.push_front(4);

	list<int>::iterator it = ls.begin();
	while (it != ls.end()) {
		cout << *it << ' ';
		++it;
	}
	cout << endl;

	ls.pop_back();
	ls.pop_back();
	ls.pop_back();
	ls.pop_back();

	ls.pop_front();
	ls.pop_front();
	ls.pop_front();
	//ls.pop_front();
	list<int>::iterator iy = ls.begin();
	while (iy != ls.end()) {
		cout << *iy << ' ';
		++iy;
	}
	cout << endl;

	cout << ls.size() << endl;
}

void test4() {
	list<int> ls;
	ls.push_back(1);
	ls.push_back(2);
	ls.push_back(3);
	ls.push_back(4);

	list<int> lt;
	lt = ls;

	list<int>::iterator it = lt.begin();
	while (it != lt.end()) {
		cout << *it << ' ';
		++it;
	}
	cout << endl;
}

void test5() {
	list<int> ls;
	ls.push_back(1);
	ls.push_back(2);
	ls.push_back(3);
	ls.push_back(4);

	list<int> lt;
	lt = ls;

	lt.clear();
	list<int>::iterator it = lt.begin();
	while (it != lt.end()) {
		cout << *it << ' ';
		++it;
	}
	cout << endl;
}

void test6() {
	list<int> ls;
	ls.push_back(1);
	ls.push_back(2);
	ls.push_back(3);
	ls.push_back(4);

	const list<int> lt = ls;

	list<int>::const_riterator it = lt.rbegin();
	while (it != lt.rend()) {
		cout << *it << ' ';
		++it;
	}
	cout << endl;
}

int main() {
	test6();
	return 0;
}